package operationSolids;

import java.io.File;

import javax.media.j3d.Appearance;
import javax.vecmath.Color3f;

import CAD.MainFrame;



public class OperationPlanarFace extends CSGSolid{

	 private float length;
	 private float width;
	 public float depth;
	 public int face;
	
	public OperationPlanarFace(String name, double depth,int face){
		super();
		calcDimensions(face);
		this.depth = (float)depth;
		this.face = face;
		
		String[] boxArg =
		{
		"8",
		"0 -5.00000000000000E-0001 -5.00000000000000E-0001 -5.00000000000000E-0001",
		"1  5.00000000000000E-0001 -5.00000000000000E-0001 -5.00000000000000E-0001",
		"2 -5.00000000000000E-0001  5.00000000000000E-0001 -5.00000000000000E-0001",
		"3  5.00000000000000E-0001  5.00000000000000E-0001 -5.00000000000000E-0001",
		"4 -5.00000000000000E-0001 -5.00000000000000E-0001  5.00000000000000E-0001",
		"5  5.00000000000000E-0001 -5.00000000000000E-0001  5.00000000000000E-0001",
		"6 -5.00000000000000E-0001  5.00000000000000E-0001  5.00000000000000E-0001",
		"7  5.00000000000000E-0001  5.00000000000000E-0001  5.00000000000000E-0001",
		"12",
		"0 0 2 3" ,
		"1 3 1 0" ,
		"2 4 5 7" ,
		"3 7 6 4" ,
		"4 0 1 5" ,
		"5 5 4 0" ,
		"6 1 3 7" ,
		"7 7 5 1" ,
		"8 3 2 6" ,
		"9 6 7 3" ,
		"10 2 0 4",
		"11 4 6 2",
		};
		
		
		loadCoordinateFile(boxArg, new Color3f(0.3f,0.3f,0.3f));
		scale(width*5, depth*5, length*5);
	
	}
	
	private void calcDimensions(int face) {
	
		switch (face) {
		case MainFrame.TOPFACE:
			width=MainFrame.block.width;
			length=MainFrame.block.length;
			break;
		case MainFrame.BACKFACE:
			width=MainFrame.block.width;
			length=MainFrame.block.height;
			break;
		case MainFrame.LOWERFACE:
			width=MainFrame.block.width;
			length=MainFrame.block.length;
			break;
		case MainFrame.WESTFACE:
			length=MainFrame.block.length;
			width=MainFrame.block.height;
			break;
		case MainFrame.EASTFACE:
			length=MainFrame.block.length;
			width=MainFrame.block.height;
			break;
		case MainFrame.FRONTFACE:
			width=MainFrame.block.width;
			length=MainFrame.block.height;
			break;

		default:
			// erro
			break;
		}
		width+=10;
		length+=10;
	}

	@Override
	public CSGSolid copy()
	{
		OperationPlanarFace box = new OperationPlanarFace(name,depth, face);
		box.updateLocation(getLocation());
		return box;
	}

}
